<%--
  ~ Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  ~ Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
  ~ Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
  ~ Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
  ~ Vestibulum commodo. Ut rhoncus gravida arcu.
  --%>

<%--
  Created by IntelliJ IDEA.
  User: dengdc
  Date: 2017/7/19
  Time: 17:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>报价协议管理</title>
    <jsp:include page="../../head.jsp"/>
    <script type="text/javascript">
        var formSetting = {
            title: "查询信息",
            module: 'query',
            columns: [{
                name: "name",
                label: "名称"
            }, {
                name: "status",
                label: "状态",
                type:'dropdown',
                data:[["生效", 1], ["待确认", 2], ["待生效", 3], ["结束", 4]]
            }, {type:'spaceHolder'}, {
                name: "eftimeStart",
                label: "生效时间起",
                type:'date'
            }, {
                name: "eftimeEnd",
                label: "至",
                type:'date'
            }],
            buttons: {
                custom: []
            },
            grid: {
                id: "protocolGrid",
                title: "查询结果",
                url: "<s:url value="/fund/protocol/biz/supConfirmGridData"/>",
                colModel: [{
                    index: "id",
                    name: "id",
                    hidden: true
                }, {
                    name: "name",
                    label: "名称",
                    align: 'center'
                }, {
                    name: "eftimeStart",
                    label: "生效时间起",
                    align: 'center'
                }, {
                    name: "eftimeEnd",
                    label: "生效时间止",
                    align: 'center'
                }, {
                    name: "remark",
                    label: "备注",
                    align: 'center'
                }, {
                    name: "file.name",
                    label: "附件",
                    align: 'center',
                    formatter:function(val, opts, row){
                        if(row.file){
                            return "<a href='javascript:downloadAtta(\""+row.file.id+"\")'>"+val+"</a>"
                        }else{
                            return "";
                        }
                    }
                }, {
                    name: "status",
                    label: "状态",
                    align: 'center',
                    formatter:function(val){
                        var statusLab = ["草稿", "生效", "待确认", "待生效", "结束"];
                        var colors = ['black', 'blue', '#cd0a0a', 'green', 'black'];
                        return "<label style='color:" + colors[val] + "'>"
                               + statusLab[val]
                               + "</label>";
                    }
                }, {
                    label: "操作",
                    sortable: false,
                    width: 120,
                    align : 'center',
                    buttons: [{
                        key: "id1",
                        value: "去确认",
                        hide:function(rowdata){
                            return rowdata.status != '2';
                        },
                        click: function (gridid, rowId, rowdata) {
                            viewProtocol(rowId, 'e');
                        }
                    }, {
                        key: "id2",
                        value: "查看",
                        hide:function(rowdata){
                            return rowdata.status == '2';
                        },
                        click: function (gridid, rowId, rowdata) {
                            viewProtocol(rowId, 'v');
                        }
                    }],
                    formatter: $.jqGrid.custom.formatter.button
                }, {
                    name: "submitor",
                    label: "提交时间/提交人",
                    width: 100,
                    align: 'center',
                    formatter:function(val, opt, row){
                        if(val){
                            return val + "<br/>" + row.submitTime;
                        }else{
                            return "";
                        }
                    }
                }, {
                    name: "confirmer",
                    label: "确认人/确认时间",
                    width: 100,
                    align: 'center',
                    formatter:function(val, opt, row){
                        if(val){
                            return val + "<br/>" + row.confirmTime;
                        }else{
                            return "";
                        }
                    }
                }],
                gridComplete:function () {
                }
            }
        };
        $(document).ready(function () {
            $("#table").mrdForm(formSetting);
        });

        function viewProtocol(id, type){
            var url = '<s:url value="/views/yxtPc/pages/offerPrice.html"/>?op=' + type + '&confirmId=' + id;
            window.location.href = url;
        }

        function downloadAtta(aid){
            var url = "<s:url value="/business/downloadSingleBizAttachment"/>?atype=declaOffer&aid=" + aid;
            $.download(url);
        }
    </script>
    <style type="text/css">
        .bold_red_font{
            font-family: bold;
            color: red;
        }

        .ui-autocomplete {
            max-height: 300px;
            overflow-y: auto;
        }
    </style>
</head>
<body>
<div id="table"></div>
</body>
</html>
